<template>
  <div>
    <!-- 头部 -->
    <div class="bgimg">
      <div>
        <router-link to="/myqrcode"
          ><van-icon name="apps-o" size="30" class="icon1"
        /></router-link>
        <router-link to="/set"><van-icon name="setting-o" size="30" /></router-link>
      </div>
     <router-link to="/upimg">
        <van-image
        :src="`${pic}`"
        round
        cover
        width="5rem"
        height="5rem"
        
      />
      
     </router-link>
      <span>{{uname}}</span>
      <img src="http://www.zlllcy.com/fuben/f15.jpg" alt="" >
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      pic:"",
      uname: "",
      pic:''
    };
  },
  methods:{
    // chagemyhead(){
    //   this.$router.push('/changeh')
    // },
    chekepage(){
      if(this.$store.state.uid){
      this.axios
      .get(`/user/avatar?uid=${this.$store.state.uid}`)
      .then((result) => {
        // 获取用户名和用户图片 渲染到界面
        // console.log(result);
        this.uname = result.data.results[0].uname;
        let pic = result.data.results[0].avator;
        this.text = result.data.results[0].intr;
          this.pic=pic;
          // console.log(pic)
    
        // console.log(this.uname, this.avator, this.text);
        // console.log(this.avator)
      });
    }
    }
  },

  /** 页面挂载完毕后执行 */
  mounted() {
    
  },
  created() {
    this.chekepage();
  },
};
</script>

<style scoped>
img{
  width: 100%;
  height: 200px;
  position: absolute;
  top: 0px;
  left: 0px;
  z-index: 0;
  opacity:0.5;
}

.bgimg div {
    z-index: 10;
  color: white;
  text-align: right;
  padding: 10px;
  box-sizing: border-box;
  position: relative;
}
.name {
  line-height: 100px;
}
.icon1 {
  margin-right: 20px;
}
span {
  font-size: 18px;
  position: absolute;
  top: 100px;
   z-index:11 ;
   font-weight : 600;
}
/* 设置router-link路由跳转样式 */
.van-icon-apps-o::before,
.van-icon-setting-o::before {
  color: white;
}
</style>